#include "input_manager.h"
#include "config.h"
#include <stdio.h>
#include <string.h>
static PT_InputEventOpr g_ptInputEventOprHead;
int RegisterInputEventOpr(PT_InputEventOpr ptInputEventOpr)
{
    if (ptInputEventOpr == NULL)
    {
        DBG_PRINTF("RegisterInputEventOpr error \n");
        return -1;
    }
    if (!g_ptInputEventOprHead)
    {
        g_ptInputEventOprHead = ptInputEventOpr;
        ptInputEventOpr->ptNext = NULL;
    }
    else
    {
        PT_InputEventOpr tmp = g_ptInputEventOprHead;
        while (tmp->ptNext != NULL)
        {
            tmp = tmp->ptNext;
        }
        tmp->ptNext = ptInputEventOpr;
        ptInputEventOpr->ptNext = NULL;
    }
    return 0;
}

int InputInit()
{
    int ret;
    ret = StdinInit();
    if (ret)
    {
        DBG_PRINTF("StdinInit error \n");
    }
    ret = TouchScreenInit();
    if (ret)
    {
        DBG_PRINTF("TouchScreenInit error \n");
    }
    return 0;
}
PT_InputEventOpr GetInputOpr(char *pcName)
{
    PT_InputEventOpr ptTmp = g_ptInputEventOprHead;
    while (ptTmp)
    {
        if (strcmp(ptTmp->name, pcName) == 0)
        {
            return ptTmp;
        }
        ptTmp = ptTmp->ptNext;
    }
    return NULL;
}

PT_InputEventOpr GetInputOprHead()
{
    return g_ptInputEventOprHead;
}

void ShowInputEventOpr(void)
{
    int i = 0;
    PT_InputEventOpr ptTmp = g_ptInputEventOprHead;

    while (ptTmp)
    {
        printf("%02d %s\n", i++, ptTmp->name);
        ptTmp = ptTmp->ptNext;
    }
}